package com.ruoze.bdp.function.impl;

import com.ruoze.bdp.constants.DataSourceConstants;
import com.ruoze.bdp.enums.DbType;
import com.ruoze.bdp.function.JDBCDataSourceFunction;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class MySQLDataSourceFunction extends JDBCDataSourceFunction {
    @Override
    public String getDriverName() {
        return DataSourceConstants.COM_MYSQL_JDBC_DRIVER;
    }

    @Override
    public String getValidationQuery() {
        return DataSourceConstants.MYSQL_VALIDATION_QUERY;
    }

    @Override
    public String getMetaDatabasesQuery() {
        return DataSourceConstants.MYSQL_META_DATABASES_QUERY;
    }

    @Override
    public String getMetaDatabasesQueryColumn() {
        return DataSourceConstants.MYSQL_META_DATABASES_QUERY_COLUMN;
    }

    @Override
    public String getMetaTablesQuery(String database) {
        return String.format(DataSourceConstants.MYSQL_META_TABLES_QUERY, database);
    }

    @Override
    public String getMetaTablesQueryColumn() {
        return DataSourceConstants.MYSQL_META_TABLES_QUERY_COLUMN;
    }

    @Override
    public String getMetaColumnsQuery(String database, String table) {
        return String.format(DataSourceConstants.MYSQL_META_COLUMNS_QUERY, database, table);
    }

    @Override
    public String getCreateTableExecQuery(String name, List<Map<String, String>> columnDefinitionList, Map<String, Object> tableOptions) {
        return null;
    }

    @Override
    public DbType getSourceType() {
        return DbType.MYSQL;
    }
}
